<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>权限管理</title>
    <link rel="stylesheet" href="{{ asset('admin_style/css/pintuer.css') }}">
    <link rel="stylesheet" href="{{ asset('admin_style/css/admin.css') }}">
    <script src="{{asset('admin_style/js/jquery.js')}}"></script>
    <script src="{{asset('admin_style/js/pintuer.js')}}"></script>
    <link rel="stylesheet" href="{{asset('admin_style/css/style.css')}}">

    <script src="{{asset('admin_style/js/layer/layer.js')}}"></script>
</head>
<body>
<div id="box">
    <div class="panel admin-panel">
        <div class="panel-head"><strong class="icon-reorder"> 权限设置</strong></div>
        <div class="panel-head"><strong class="icon-reorder"> 当前组：{{$row->r_name}} </strong></div>
    </div>
    <div style="border: 1px solid blue;width: 250px;height:150px;background-color: gainsboro">
        请选择：
        <select style="width: 192px" id="select_id">
            @foreach($data1 as $v)
            <option value="{{$v->id}}">{{$v->n_name}}</option>
            @endforeach
        </select>
        <table style="margin-top: 40px">
            @foreach($data2 as $v)
            <tr>
                <td><input type="checkbox" name="check"  value="{{$v->sq_id}}" />{{$v->name}}</td>
            </tr>
            {{--@for($f=0;$f<count($nums);$f++)--}}
            {{--@if($v->sq_id == $nums[$f])--}}
            {{--<tr>--}}
                {{--<td><input type="checkbox" name="check" checked="checked" value="{{$v->sq_id}}" />{{$v->name}}</td>--}}
                {{--</tr>--}}
            {{--@else--}}
            {{--<tr>--}}
                {{--<td><input type="checkbox" name="check" value="{{$v->sq_id}}" />{{$v->name}}</td>--}}
                {{--</tr>--}}
            {{--@endif--}}
            {{--@endfor--}}
            @endforeach
        </table>
    </div>
    <input type="hidden" id="aid" value="{{$row->r_id}}">
    <input class="button bg-red" type="submit" value="确定" onclick="submit()">
</div>
</body>
</html>
<script>
    function submit() {
        var rid = document.getElementById('aid').value;
        var selected_val = document.getElementById('select_id').value;
        var check = document.getElementsByName('check');
        var str = " ";
        var ids=[];
        for(var i=0;i<check.length;i++){
            if(check[i].checked){
                ids.push(check[i].value);
            }
        }
        var str = ids.join(',');
        var xh      = new XMLHttpRequest();
        xh.open('get',"{{url('node/module/')}}/"+rid+'/'+str+'/'+selected_val,true);
        xh.send();
        xh.onreadystatechange = function(){
            if(xh.readyState == 4 && xh.status==200){
                document.getElementById('box').innerHTML=xh.responseText;
            }
        }
    }
</script>
@foreach($data2 as $v)
{{--<tr>--}}
    {{--<td><input type="checkbox" name="check"  value="{{$v->sq_id}}" />{{$v->name}}</td>--}}
    {{--</tr>--}}
@for($f=0;$f<count($nums);$f++)
@if($v->sq_id == $nums[$f])
<tr>
    <td><input type="checkbox" name="check" checked="checked" value="{{$v->sq_id}}" />{{$v->name}}</td>
</tr>
@else
<tr>
    <td><input type="checkbox" name="check" value="{{$v->sq_id}}" />{{$v->name}}</td>
</tr>
@endif
@endfor
@endforeach